package homeworkplus.day02;

import java.util.Objects;

/**
 * @Classname: Person
 * @Author: bromide
 * @CreateTime: 2022/3/29--20:04
 * @Version: V1.0
 * @Desciption: 定义私有属性:
 * String name;
 * int age;
 * String gender;
 * int salary;
 * 定义全参数(该构造方法的参数用于设置所有属性)构造方法与默认构造方法
 * 重写toString方法，返回字符串格式如:"张三,25,男,5000"
 * 重写equals方法，要求名字相同就认为内容一致。
 */
public class Person {
    private String name;        //名字
    private int age;            //年龄
    private String gender;      //性别
    private int salary;         //工资

    public Person() {
    }

    public Person(String name, int age, String gender, int salary) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.salary = salary;
    }

    public String toString() {
        return name + "," + age + "," + gender + "," + salary;
    }

    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Person person = (Person) o;
        return Objects.equals(name, person.name);

    }

}
